'use strict';

/* Controllers */


function scheduleCtrl($scope,$http,$location,$stateParams) {
	$scope.isCollapsed = false;
	nexus.scheduleForm=$scope;
	
	$scope.schedule = function (){
	
        var ploc=$location.url();
//        if(nexus.headerScope.notLogin){
//                nexus.headerScope.turl=function(){
//                        //$location.path();
//                        $location.url(ploc);
//                };
//                nexus.headerScope.showLogin();
//                return;
//        }

	 var reqData = {"description" : $('#message').val(), "startTime": $('#datetimepicker1').data('datetimepicker').getDate(), "endTime": $('#datetimepicker2').data('datetimepicker').getDate(),"email":$('#email').text()};
      
	 var userListRef = new Firebase("https://adviseme.firebaseio.com/");
	 var myUserRef = userListRef.child($stateParams.id);
	 
	 
	 $http.post('counsel/'+ $stateParams.id+'/addCounselRequest', reqData).success(function(data) {
		myUserRef.set({ message: $('#message').val()});
		$location.path('/dashboard/feed');
	});
	
		//}
	};
}
scheduleCtrl.$inject = ['$scope','$http','$location','$stateParams'];